package com.doctor.windflower_doctor.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.doctor.windflower_doctor.R;


public class NumAdapter extends BaseAdapter {
	public Context context;
	private List<String> lists;
	private LayoutInflater inflater;
	private int currentposition = 1;

	public NumAdapter(Context context) {
		this.context = context;
		this.inflater = LayoutInflater.from(context);
		this.lists = new ArrayList<String>();
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lists.size();
	}

	@Override
	public Object getItem(int position) {
		if (!lists.isEmpty())
			return lists.get(position);
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.list_scorll, null);
			holder.num_text = (TextView) convertView.findViewById(R.id.number_text);
			holder.num_text.setTextColor(Color.BLACK);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (lists.get(position)!=null) {
			
			holder.num_text.setText(lists.get(position) + "");
		} else {
			holder.num_text.setText(null);
		}
	

		return convertView;
	}

	class ViewHolder {
		TextView num_text;
	}

	public void addList(List<String> lists) {
		if (!lists.isEmpty()) {
			this.lists.addAll(lists);
			notifyDataSetChanged();
		}
	}

	public void clearDate() {
		if (!this.lists.isEmpty()) {
			this.lists.clear();
			notifyDataSetChanged();
		}
	}

	public void setPosition(int position) {
		this.currentposition = position;
		notifyDataSetChanged();
	}
}
